---
title: WRITER LLM
---

[WRITER](https://writer.com/) is a platform to generate different language content.

This example goes over how to use LangChain to interact with `WRITER` [models](https://dev.writer.com/docs/models).

## Setup

To access WRITER models you'll need to create a WRITER account, get an API key, and install the `writer-sdk` and `langchain-community` packages.

### Credentials

Head to [WRITER AI Studio](https://app.writer.com/aistudio/signup?utm_campaign=devrel) to sign up for WRITER and generate an API key. Once you've done this set the WRITER_API_KEY environment variable:

```python
import getpass
import os

if not os.environ.get("WRITER_API_KEY"):
    os.environ["WRITER_API_KEY"] = getpass.getpass("Enter your Writer API key:")
```

## Installation

The LangChain WRITER integration lives in the `langchain-community` package:

```python
%pip install -qU langchain-community writer-sdk
```

```output
[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: pip install -U pip
Note: you may need to restart the kernel to use updated packages.
```

Now we can initialize our model object to interact with writer LLMs

```python
from langchain_community.llms import Writer as WriterLLM

llm = WriterLLM(
    temperature=0.7,
    max_tokens=1000,
    # other params...
)
```

## Invocation

```python
response_text = llm.invoke(input="Write a poem")
```

```python
print(response_text)
```

## Streaming

```python
stream_response = llm.stream(input="Tell me a fairytale")
```

```python
for chunk in stream_response:
    print(chunk, end="")
```

## Async

WRITER support asynchronous calls via **ainvoke()** and **astream()** methods

## API reference

For detailed documentation of all WRITER features, head to our [API reference](https://dev.writer.com/api-guides/api-reference/completion-api/text-generation#text-generation).
